package xyz.scootaloo.code.adt;

/**
 * @author flutterdash@qq.com
 * @since 2021/11/14 19:16
 */
public class BinaryNode<E extends Comparable<? super E>> {

    public E value;
    public BinaryNode<E> left;
    public BinaryNode<E> right;

    public BinaryNode(E value) {
        this(value, null, null);
    }

    public BinaryNode(E value, BinaryNode<E> left, BinaryNode<E> right) {
        this.value = value;
        this.left = left;
        this.right = right;
    }

    @Override
    public String toString() {
        return String.format("Node(V=%s, L=%s, R=%s)", value,
                (left == null ? "null" : left.value),
                (right == null ? "null" : right.value));
    }
}
